<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tt_exp2</title>
  <meta name="keywords" content="tt_exp2">
  <meta name="description" content="Computation of the matrix exponential of a matrix in TT format">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">exp</a> &gt; tt_exp2.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/exp&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>tt_exp2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>Computation of the matrix exponential of a matrix in TT format</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [tt]=tt_exp2(mat,eps,N,rmax) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">Computation of the matrix exponential of a matrix in TT format
   [TT]=TT_EXP2(MAT,EPS,N,RMAX) This function computes matrix exponential
   using scaling and squaring method of the TT-matrix TT. EPS is the
   accuracy parameter, N is the number of summand for the local Taylor
   series (N=10 is usually enough). RMAX is the TT-rank bound and TT_MAT
   is the result


 TT-Toolbox 2.2, 2009-2011

This is TT Toolbox, written by Ivan Oseledets, Olga Lebedeva
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------
d=size(tt,1);
n=size(tt{1},1); %Warning: only equal sizes are valid here
e=tt_eye(n,d);
xs=tt_random(n*n,d,rmax); 
xs=tt_vec_to_mat(xs,n,n);</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@qtt_tucker/round.html" class="code" title="function [tt]=round(tt,varargin)">round</a>	Approximate QTT-Tucker with another one with specified accuracy</li><li><a href="../../tt2/@tt_matrix/ndims.html" class="code" title="function d = ndims(tt)">ndims</a>	Number of dimensions of a TT-matrix</li><li><a href="../../tt2/@tt_matrix/round.html" class="code" title="function [tt]=round(tt,eps,rmax)">round</a>	Approximate TT-matrix with another one with specified accuracy</li><li><a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>	Mode sizes of the TT-matrix</li><li><a href="../../tt2/@tt_matrix/tt_matrix.html" class="code" title="function t = tt_matrix(varargin)">tt_matrix</a>	TT_matrix class constructor</li><li><a href="../../tt2/@tt_tensor/ndims.html" class="code" title="function d = ndims(tt)">ndims</a>	Number of dimensions of a tensor</li><li><a href="../../tt2/@tt_tensor/round.html" class="code" title="function [tt]=round(tt,varargin)">round</a>	Approximate TT-tensor with another one with specified accuracy</li><li><a href="../../tt2/@tt_tensor/size.html" class="code" title="function [sz] = size(tt,dim)">size</a>	Mode sizes of the TT-tensor</li><li><a href="../../tt2/core/tt_eye.html" class="code" title="function [e]=tt_eye(n,varargin)">tt_eye</a>	Identity matrix in the TT-format</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [tt]=tt_exp2(mat,eps,N,rmax)</a>
0002 <span class="comment">%Computation of the matrix exponential of a matrix in TT format</span>
0003 <span class="comment">%   [TT]=TT_EXP2(MAT,EPS,N,RMAX) This function computes matrix exponential</span>
0004 <span class="comment">%   using scaling and squaring method of the TT-matrix TT. EPS is the</span>
0005 <span class="comment">%   accuracy parameter, N is the number of summand for the local Taylor</span>
0006 <span class="comment">%   series (N=10 is usually enough). RMAX is the TT-rank bound and TT_MAT</span>
0007 <span class="comment">%   is the result</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% TT-Toolbox 2.2, 2009-2011</span>
0011 <span class="comment">%</span>
0012 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets, Olga Lebedeva</span>
0013 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0014 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0015 <span class="comment">%</span>
0016 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0017 <span class="comment">%ivan.oseledets@gmail.com</span>
0018 <span class="comment">%---------------------------</span>
0019 <span class="comment">%d=size(tt,1);</span>
0020 <span class="comment">%n=size(tt{1},1); %Warning: only equal sizes are valid here</span>
0021 <span class="comment">%e=tt_eye(n,d);</span>
0022 <span class="comment">%xs=tt_random(n*n,d,rmax);</span>
0023 <span class="comment">%xs=tt_vec_to_mat(xs,n,n);</span>
0024 <span class="keyword">if</span> ( nargin == 3) 
0025   rmax=1000;
0026 <span class="keyword">end</span>
0027 nrm=abs(norm2(mat));
0028 
0029 n0=floor(max(floor(log2(10*nrm)),0))+1;
0030 w0=mat*(1.0/2^n0);
0031 sz=<a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>(mat); sz=sz(:,1);
0032 e=<a href="../../tt2/core/tt_eye.html" class="code" title="function [e]=tt_eye(n,varargin)">tt_eye</a>(sz,<a href="../../tt2/@tt_matrix/ndims.html" class="code" title="function d = ndims(tt)">ndims</a>(mat)); e=<a href="../../tt2/@tt_matrix/tt_matrix.html" class="code" title="function t = tt_matrix(varargin)">tt_matrix</a>(e);
0033 tt=e;
0034 
0035 <span class="keyword">for</span> k=(N-1):-1:1
0036     <span class="comment">%fprintf('Iteration %d/1 \n',k);</span>
0037     <span class="comment">%if ( tt_erank(tt_mat)*tt_erank(w0) &gt; rmax )</span>
0038     <span class="comment">%  tt_mat=ttm_add(tt_scal(tt_mmals(tt_mat,w0,xs,3),1.0/k),e);</span>
0039     <span class="comment">%else</span>
0040     <span class="comment">%  tt_mat=ttm_add(tt_scal(tt_mm(tt_mat,w0),1.0/k),e);</span>
0041     <span class="comment">%end</span>
0042     tt=e+(tt*w0)/k;
0043     tt=<a href="../../tt2/@qtt_tucker/round.html" class="code" title="function [tt]=round(tt,varargin)">round</a>(tt,eps);
0044     <span class="comment">%tt_mat=tt_mat_compr(tt_mat,eps);</span>
0045 <span class="keyword">end</span>
0046 <span class="comment">%keyboard;</span>
0047 <span class="keyword">for</span> k=1:n0
0048    <span class="comment">% reff=sqrt(tt_mem(tt_mat)/(n*n*d));</span>
0049    <span class="comment">%fprintf('Iteration %d/%d Rank=%3.2f\n',k,n0,reff);</span>
0050    tt=<a href="../../tt2/@qtt_tucker/round.html" class="code" title="function [tt]=round(tt,varargin)">round</a>(tt*tt,eps,rmax);
0051    <span class="comment">%else</span>
0052    <span class="comment">%  tt_mat=tt_mm(tt_mat,tt_mat);</span>
0053    <span class="comment">%end</span>
0054    <span class="comment">%tt_mat=tt_mat_compr(tt_mat,eps);</span>
0055    <span class="comment">%fprintf('nrm=%3.2e \n',tt_dot(tt_mat1,tt_mat1));</span>
0056 <span class="keyword">end</span>
0057 
0058 <span class="keyword">return</span>
0059 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>